package ${package.Controller};

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tele.common.bean.Query;
import com.tele.common.vo.Result;
import ${package.Service}.${table.serviceName};
import ${cfg.EntityVo}.${table.entityName}VO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ${author}
 * @version 1.0
 * @date ${.now}
 * @Description ${table.comment}控制层
 */
@Api(tags = "${table.comment}管理")
@RestController
@RequestMapping("/${table.entityPath}")
public class ${table.controllerName} {

    @Autowired
    private ${table.serviceName} ${table.entityPath}Service;

    /**
     * 分页获取${table.comment}列表
     *
     * @param query 查询参数
     * @return {@link Result}
     */
    @ApiOperation(notes = "分页获取${table.comment}列表", value = "分页获取${table.comment}列表")
    @GetMapping("/page${table.entityName}")
    public Result<Page<${table.entityName}VO>> page${table.entityName}(Query<${table.entityName}VO> query) {
        return ${table.entityPath}Service.findPage(query);
    }

    /**
     * 新增${table.comment}信息
     *
     * @param ${table.entityPath} ${table.comment}
     * @return {@link Result}
     */
    @ApiOperation(notes = "新增${table.comment}信息", value = "新增${table.comment}信息")
    @PostMapping("/add${table.entityName}")
    public Result<String> add${table.entityName}(@RequestBody ${table.entityName}VO ${table.entityPath}) {
        return ${table.entityPath}Service.add${table.entityName}(${table.entityPath});
    }

    /**
     * 修改${table.comment}信息
     *
     * @param ${table.entityPath} ${table.comment}
     * @return {@link Result}
     */
    @ApiOperation(notes = "修改${table.comment}信息，id必传", value = "修改${table.comment}信息")
    @PostMapping("/update${table.entityName}")
    public Result<String> update${table.entityName}(@RequestBody ${table.entityName}VO ${table.entityPath}) {
        return ${table.entityPath}Service.update${table.entityName}(${table.entityPath});
    }

    /**
     * 删除${table.comment}信息
     *
     * @param ids ${table.comment}Id
     * @return {@link Result}
     */
    @ApiOperation(notes = "删除${table.comment}（${table.comment}Ids，用小写逗号分隔）", value = "删除${table.comment}")
    @DeleteMapping("/delete${table.entityName}/{ids}")
    public Result<String> delete${table.entityName}(@PathVariable("ids") List<String> ids) {
        return ${table.entityPath}Service.deleteByIds(ids);
    }
}